﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class User_DangKy : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void bthuy_Click(object sender, EventArgs e)
    {
        txtht.Text = "";
        txttk.Text = "";
        txtmk.Text = "";
        txtrmk.Text = "";
        txtemail.Text = "";
        txtdc.Text = "";
        txtdt.Text = "";
    }
    protected void btreg_Click(object sender, EventArgs e)
    {
        if (txtht.Text != "" && txttk.Text != "" && txtmk.Text != "" && txtrmk.Text != "" && txtemail.Text != "" && txtdc.Text != "" && txtdt.Text != "")
        {
            tbKhachHangEntities kh = new tbKhachHangEntities();
            kh.HoTen = txtht.Text;
            kh.TaiKhoan = txttk.Text;
            kh.MatKhau = txtmk.Text;
            kh.GioiTinh = ddl.SelectedValue;
            kh.Email = txtemail.Text;
            kh.DiaChi = txtdc.Text;
            kh.DienThoai = txtdt.Text;
            string user = txttk.Text;

            if (txtrmk.Text != txtmk.Text)
                lberror2.Visible = true;
                lberror2.Text = "(*)Nhập sai mật khẩu.";

            if (tbKhachHangBUS.KTKhachHang2(user))
            {
                lberror1.Visible = true;
                lberror1.Text = "(*)Tài khoản đã được sử dụng.";
            }

            else
            {
                tbKhachHangBUS.Insert(kh);
                Response.Redirect("Default.aspx");
            }
        }
    }
}
